<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts: lib/timer.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">ESP8266ILI9341DisplayProject</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_97aefd0d527b934f1d99a682da8fe6a9.html">lib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">timer.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="timer_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="user__config_8h.html">user_config.h</a>&quot;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#ifdef AVR</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#define HAVE_HIRES_TIMER </span><span class="comment">/*&lt; We can read a high resolution hardware timer */</span><span class="preprocessor"></span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="mathio_8h.html">printf/mathio.h</a>&quot;</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="time_8h.html">lib/time.h</a>&quot;</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="timer_8h.html">lib/timer.h</a>&quot;</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="timer_8c.html#a335451dd774ecb4b696d501b4c1b6f30">   38</a></span>&#160;<span class="keyword">volatile</span> <a class="code" href="structtimespec.html">ts_t</a> <a class="code" href="timer_8c.html#a335451dd774ecb4b696d501b4c1b6f30">__clock</a>;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="timer_8c.html#a9ac29ed71adf6807175d24ab1fa622a7">   41</a></span>&#160;<a class="code" href="structtimezone.html">tz_t</a> <a class="code" href="timer_8c.html#a9ac29ed71adf6807175d24ab1fa622a7">__tzone</a>;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">   43</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a> = 0;</div><div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">   44</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a> = 0;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="timer_8c.html#ad680b46025f0dae867f27a80344736a1">   47</a></span>&#160;<a class="code" href="structTIMERS.html">TIMERS</a> <a class="code" href="timer_8c.html#ad680b46025f0dae867f27a80344736a1">timer_irq</a>[<a class="code" href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a>];</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="timer_8h.html#a35f94fb84f1b626d8d1ace062b26c932">   60</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="timer_8c.html#a35f94fb84f1b626d8d1ace062b26c932">set_timers</a>(<span class="keywordtype">void</span> (*handler)(<span class="keywordtype">void</span>), <span class="keywordtype">int</span> timer)</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;{</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keywordtype">int</span> ret = -1;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">if</span>(!handler)</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        <span class="keywordflow">return</span> -1;</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordflow">for</span>(i=0;i&lt;<a class="code" href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a>;++i)</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    {</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        <span class="comment">// already assigned</span></div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">if</span>(timer_irq[i].user_timer_handler == handler)</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            ret = i;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        <span class="keywordflow">if</span>(!timer_irq[i].user_timer_handler)</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;            timer_irq[i].<a class="code" href="structTIMERS.html#a0b10fdb7b0e6b1d3ca49718f47c4514d">timer</a> = 0;   <span class="comment">// Set to disable</span></div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;            timer_irq[i].<a class="code" href="structTIMERS.html#a4326e05ca52d80147efafd0d246ecb41">user_timer_handler</a> = handler;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            timer_irq[i].<a class="code" href="structTIMERS.html#a0b10fdb7b0e6b1d3ca49718f47c4514d">timer</a> = 1;      <span class="comment">// Set if enabled, 0 if not</span></div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            ret = i;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;            <span class="keywordflow">break</span>;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        }</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    }</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordflow">if</span>(ret == -1)</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;set_timers: No more timers!\n&quot;</span>);</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordflow">return</span>(ret);</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;}</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00100"></a><span class="lineno"><a class="line" href="timer_8h.html#a71c3fe0e245c7b08e03a2fe0fbd88844">  100</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="timer_8c.html#a71c3fe0e245c7b08e03a2fe0fbd88844">kill_timer</a>( <span class="keywordtype">int</span> timer )</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;{</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    <span class="keywordtype">int</span> ret = -1;</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="keywordflow">if</span>(timer &gt;= 0 &amp;&amp; timer &lt;= <a class="code" href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a>)</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    {</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;        timer_irq[timer].<a class="code" href="structTIMERS.html#a0b10fdb7b0e6b1d3ca49718f47c4514d">timer</a> = 0;               <span class="comment">// Disable</span></div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        timer_irq[timer].<a class="code" href="structTIMERS.html#a4326e05ca52d80147efafd0d246ecb41">user_timer_handler</a> = 0;</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        ret = timer;</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    }</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keywordflow">return</span>(ret);</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;}</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="timer_8h.html#a4b27b84577f0a45741aa4b1de370df66">  117</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a62b37d3b3acfee789af6a9dbd47f7267">delete_all_timers</a>()</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;{</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    <span class="keywordflow">for</span>(i=0; i &lt; <a class="code" href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a>; i++)</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    {</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        timer_irq[i].<a class="code" href="structTIMERS.html#a0b10fdb7b0e6b1d3ca49718f47c4514d">timer</a> = 0;                   <span class="comment">// Disable</span></div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;        timer_irq[i].<a class="code" href="structTIMERS.html#a4326e05ca52d80147efafd0d246ecb41">user_timer_handler</a> = 0;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    }</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;}</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00135"></a><span class="lineno"><a class="line" href="timer_8h.html#ab92d687bae984bd62c3d741f2ba614ed">  135</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#ab92d687bae984bd62c3d741f2ba614ed">subtract_timespec</a>(<a class="code" href="structtimespec.html">ts_t</a> *a, <a class="code" href="structtimespec.html">ts_t</a> *b)</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;{</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    a-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = a-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> - b-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a>;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <span class="keywordflow">if</span> (a-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> &lt; 0<a class="code" href="cal__dex_8c.html#a7577d49f3bfffb1cf048eef843177784">L</a>)</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    {</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        a-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> += 1000000000<a class="code" href="cal__dex_8c.html#a7577d49f3bfffb1cf048eef843177784">L</a>;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;        a-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> --;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    }</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    a-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> = a-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> - b-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;}</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno"><a class="line" href="timer_8c.html#a3b37602023ba3cdbbe1394f43abbef2c">  153</a></span>&#160;<span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="timer_8c.html#a3b37602023ba3cdbbe1394f43abbef2c">_ts_to_str</a>[32];</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00155"></a><span class="lineno"><a class="line" href="timer_8h.html#a41fb2edea84c2f17c7c6ad6ff87baeff">  155</a></span>&#160;<span class="keywordtype">char</span> * <a class="code" href="timer_8c.html#a41fb2edea84c2f17c7c6ad6ff87baeff">ts_to_str</a>(<a class="code" href="structtimespec.html">ts_t</a> *val)</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;{</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <a class="code" href="cpu_8h.html#a8ca99a0a57619094a5bff3a009b5cea8">snprintf</a>(_ts_to_str,31,<span class="stringliteral">&quot;%ld.%09ld&quot;</span>, val-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>, val-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a>);</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    <span class="keywordflow">return</span>( _ts_to_str );</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;}</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00167"></a><span class="lineno"><a class="line" href="timer_8h.html#a6802af23bc1fe764b975683a0b37fc91">  167</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a6802af23bc1fe764b975683a0b37fc91">display_ts</a>(<a class="code" href="structtimespec.html">ts_t</a> *val)</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;{</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;    <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;[Seconds: %s]\n&quot;</span>, <a class="code" href="timer_8c.html#a41fb2edea84c2f17c7c6ad6ff87baeff">ts_to_str</a>(val) );</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;}</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;</div><div class="line"><a name="l00176"></a><span class="lineno"><a class="line" href="timer_8c.html#a11d81711e20909cf489fb56cbbb81558">  176</a></span>&#160;<span class="keyword">static</span> <a class="code" href="structtimespec.html">ts_t</a> <a class="code" href="timer_8c.html#a11d81711e20909cf489fb56cbbb81558">__clock_elapsed</a>;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00184"></a><span class="lineno"><a class="line" href="timer_8h.html#a6beae313733d5f16cb62417d41eaca95">  184</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#adf029ed50e104cc3c16bcb7cf7d58f8c">clock_elapsed_begin</a>()</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;{</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    <a class="code" href="timer_8c.html#aa6e5b6a9c1fb8bc6e2093fca40600bf5">clock_gettime</a>(0, (<a class="code" href="structtimespec.html">ts_t</a> *) &amp;__clock_elapsed);</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;}</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="timer_8h.html#a9f3dff4c1cc1701dc99d7e1d30ffcc06">  200</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a9f3dff4c1cc1701dc99d7e1d30ffcc06">clock_elapsed_end</a>(<span class="keywordtype">char</span> *msg)</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;{</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    <a class="code" href="structtimespec.html">ts_t</a> current;</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    <a class="code" href="timer_8c.html#aa6e5b6a9c1fb8bc6e2093fca40600bf5">clock_gettime</a>(0, (<a class="code" href="structtimespec.html">ts_t</a> *) &amp;current);</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;    <a class="code" href="timer_8c.html#ab92d687bae984bd62c3d741f2ba614ed">subtract_timespec</a>((<a class="code" href="structtimespec.html">ts_t</a> *) &amp;current, (<a class="code" href="structtimespec.html">ts_t</a> *) &amp;__clock_elapsed);</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    <span class="keywordflow">if</span>(msg &amp;&amp; *msg)</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;        <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;[%s Time:%s]\n&quot;</span>, msg, <a class="code" href="timer_8c.html#a41fb2edea84c2f17c7c6ad6ff87baeff">ts_to_str</a>((<a class="code" href="structtimespec.html">ts_t</a> *) &amp;current) );</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="keywordflow">else</span></div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;        <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;[Time:%s]\n&quot;</span>, <a class="code" href="timer_8c.html#a41fb2edea84c2f17c7c6ad6ff87baeff">ts_to_str</a>((<a class="code" href="structtimespec.html">ts_t</a> *) &amp;current) );</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;}</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00221"></a><span class="lineno"><a class="line" href="timer_8h.html#a23ba64ca0da1fe41d4c870ada3e8a04e">  221</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a7faad7f12590c5756441f44a069f60d5">clock_clear</a>()</div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;{</div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;    <span class="keyword">struct </span><a class="code" href="structtimespec.html">timespec</a> ts;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;    ts.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = 0;</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;    ts.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> = 0;</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    <a class="code" href="timer_8c.html#a4ebca9883466f2cc6fea0547e0e64e79">clock_settime</a>(0, &amp;ts);</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    __tzone.<a class="code" href="structtimezone.html#a3042f7eff6e1b980728def76b1fa0eb7">tz_minuteswest</a> = 0;</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    __tzone.<a class="code" href="structtimezone.html#a85259977aeb63b17e6ce94f19afdfd99">tz_dsttime</a> = 0;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;}</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00235"></a><span class="lineno"><a class="line" href="timer_8h.html#abe2823a39b30ff55fe9326f2b5f0741e">  235</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a296c5d3efac4bc56fc12fe3626f7d4b6">disable_timers</a>()</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;{</div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a> &amp;&amp; <a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a>)</div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;    {</div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        <a class="code" href="timer_8h.html#a45ccd72c3ad32c4f7a5a8ef74d2653b3">disable_system_task</a>();</div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        <a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a> = 0;</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;    }</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;}</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00248"></a><span class="lineno"><a class="line" href="timer_8h.html#a0e736ce66a2bc05cc14b7a282fa52b73">  248</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#ac97e80c15c73721fbc9f5071f6681fac">enable_timers</a>()</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;{</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a> &amp;&amp; !<a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a>)</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;    {</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;        <a class="code" href="timer_8h.html#a9827e02881cff25ff30c35c7d8ed3ac4">enable_system_task</a>();</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;        <a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a> = 1;</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;    }</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;}</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;</div><div class="line"><a name="l00261"></a><span class="lineno"><a class="line" href="timer_8h.html#a7de37276c1b697f865594c7e5f28e961">  261</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a67a27354654cf2a2169137adc7274def">execute_timers</a>()</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;{</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;    <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    <span class="keywordflow">for</span>(i=0; i &lt; <a class="code" href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a>; i++)</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;    {</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;        <span class="keywordflow">if</span>(timer_irq[i].timer &amp;&amp; timer_irq[i].user_timer_handler != <a class="code" href="cpu_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;            (*timer_irq[i].<a class="code" href="structTIMERS.html#a4326e05ca52d80147efafd0d246ecb41">user_timer_handler</a>)();</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;    }</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;}</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;</div><div class="line"><a name="l00276"></a><span class="lineno"><a class="line" href="timer_8h.html#a182d70e09e9436c9c8a2e81b7597f206">  276</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#a182d70e09e9436c9c8a2e81b7597f206">clock_task</a>(<span class="keywordtype">void</span>)</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;{</div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;    __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> += 1000000;</div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;    <span class="keywordflow">if</span>(__clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> &gt;= 1000000000<a class="code" href="cal__dex_8c.html#a7577d49f3bfffb1cf048eef843177784">L</a>)</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    {</div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;        __clock.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>++;</div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;        __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = 0;</div><div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;    }</div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;}</div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;</div><div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;<span class="comment"></span><a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00293"></a><span class="lineno"><a class="line" href="timer_8h.html#a4a06b0b10204f441d18c79601b4ee13f">  293</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="timer_8c.html#acb0c9c995c634465d7d1f534bd862f8e">init_timers</a>()</div><div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;{</div><div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;    <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Timers init called\n&quot;</span>);</div><div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;</div><div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a>)</div><div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;    {</div><div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;        <a class="code" href="timer_8h.html#a49353e09a3623d95083574b87e9aadc5">install_timers_isr</a>();</div><div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;        <a class="code" href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a> = 1;</div><div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;        <a class="code" href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a> = 0;</div><div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;        <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Timers configured\n&quot;</span>);</div><div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;    }</div><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;</div><div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;    <a class="code" href="timer_8c.html#a62b37d3b3acfee789af6a9dbd47f7267">delete_all_timers</a>();</div><div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;</div><div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;    <a class="code" href="timer_8c.html#a7faad7f12590c5756441f44a069f60d5">clock_clear</a>();</div><div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;    <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Clock Init\n&quot;</span>);</div><div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;</div><div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="timer_8c.html#a35f94fb84f1b626d8d1ace062b26c932">set_timers</a>(<a class="code" href="timer_8c.html#a182d70e09e9436c9c8a2e81b7597f206">clock_task</a>,1) == -1)</div><div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;        <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Clock task init failed\n&quot;</span>);</div><div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;    <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Clock Installed\n&quot;</span>);</div><div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;</div><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;    <a class="code" href="timer_8c.html#ac97e80c15c73721fbc9f5071f6681fac">enable_timers</a>();</div><div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;</div><div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;    <a class="code" href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a>(<span class="stringliteral">&quot;Timers enabled\n&quot;</span>);</div><div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;}</div><div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;</div><div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;</div><div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00329"></a><span class="lineno"><a class="line" href="timer_8h.html#ab507661341c93c415b27ed9d40839539">  329</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="timer_8c.html#ab507661341c93c415b27ed9d40839539">clock_getres</a>(<a class="code" href="time_8h.html#afeece078c6706f33383bf11bbf584518">clockid_t</a> clk_id, <span class="keyword">struct</span> <a class="code" href="structtimespec.html">timespec</a> *res)</div><div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;{</div><div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;    res-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> = 0;</div><div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;    res-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = <a class="code" href="timer_8h.html#ac0ca52f7bb0e2b7993bbcb75495d7904">SYSTEM_TASK_TIC_NS</a>;</div><div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;    <span class="keywordflow">return</span>(0);</div><div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;}</div><div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;</div><div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;</div><div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00345"></a><span class="lineno"><a class="line" href="timer_8h.html#a4ebca9883466f2cc6fea0547e0e64e79">  345</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="timer_8c.html#a4ebca9883466f2cc6fea0547e0e64e79">clock_settime</a>(<a class="code" href="time_8h.html#afeece078c6706f33383bf11bbf584518">clockid_t</a> clk_id, <span class="keyword">const</span> <span class="keyword">struct</span> <a class="code" href="structtimespec.html">timespec</a> *ts)</div><div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;{</div><div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;    <span class="keywordflow">if</span>(clk_id)</div><div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;        <span class="keywordflow">return</span>(-1);</div><div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;</div><div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;    <span class="keywordflow">while</span>(1)</div><div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;    {</div><div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;        __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = ts-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a>;</div><div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;        __clock.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>  = ts-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>;</div><div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;</div><div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;        <span class="keywordflow">if</span>(ts-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> != __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> || ts-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> != __clock.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>)</div><div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;            <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;        <span class="keywordflow">break</span>;</div><div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;    }</div><div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;</div><div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;    <span class="keywordflow">return</span>(0);</div><div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;}</div><div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;</div><div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;<span class="preprocessor">#if ! defined(HAVE_HIRES_TIMER) </span></div><div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;</div><div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;<span class="comment">//TODO try to use system_get_time() to get microsecond offsets</span></div><div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;<a class="code" href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="line"><a name="l00377"></a><span class="lineno"><a class="line" href="timer_8h.html#aa6e5b6a9c1fb8bc6e2093fca40600bf5">  377</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="timer_8c.html#aa6e5b6a9c1fb8bc6e2093fca40600bf5">clock_gettime</a>(<a class="code" href="time_8h.html#afeece078c6706f33383bf11bbf584518">clockid_t</a> clk_id, <span class="keyword">struct</span> <a class="code" href="structtimespec.html">timespec</a> *ts)</div><div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;{</div><div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;    ts-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = 0;</div><div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    ts-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> = 0;</div><div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;</div><div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;    <span class="keywordflow">while</span>(1)</div><div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;    {</div><div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;        ts-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> = __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a>;</div><div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;        ts-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> = __clock.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>;</div><div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;        <span class="keywordflow">if</span>(ts-&gt;<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> != __clock.<a class="code" href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">tv_nsec</a> || ts-&gt;<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a> != __clock.<a class="code" href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">tv_sec</a>)</div><div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;            <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;        <span class="keywordflow">break</span>;</div><div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    }</div><div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;    <span class="keywordflow">return</span>(0);</div><div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;}</div><div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;</div><div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="structtimezone_html_a85259977aeb63b17e6ce94f19afdfd99"><div class="ttname"><a href="structtimezone.html#a85259977aeb63b17e6ce94f19afdfd99">timezone::tz_dsttime</a></div><div class="ttdeci">int tz_dsttime</div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00081">time.h:81</a></div></div>
<div class="ttc" id="structTIMERS_html_a0b10fdb7b0e6b1d3ca49718f47c4514d"><div class="ttname"><a href="structTIMERS.html#a0b10fdb7b0e6b1d3ca49718f47c4514d">TIMERS::timer</a></div><div class="ttdeci">uint8_t timer</div><div class="ttdef"><b>Definition:</b> <a href="timer_8h_source.html#l00038">timer.h:38</a></div></div>
<div class="ttc" id="timer_8c_html_ad680b46025f0dae867f27a80344736a1"><div class="ttname"><a href="timer_8c.html#ad680b46025f0dae867f27a80344736a1">timer_irq</a></div><div class="ttdeci">TIMERS timer_irq[MAX_TIMER_CNT]</div><div class="ttdoc">array or user timers </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00047">timer.c:47</a></div></div>
<div class="ttc" id="timer_8c_html_a67a27354654cf2a2169137adc7274def"><div class="ttname"><a href="timer_8c.html#a67a27354654cf2a2169137adc7274def">execute_timers</a></div><div class="ttdeci">void execute_timers()</div><div class="ttdoc">Execute all user timers at SYSTEM_HZ rate. Called by system task. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00261">timer.c:261</a></div></div>
<div class="ttc" id="user__config_8h_html"><div class="ttname"><a href="user__config_8h.html">user_config.h</a></div><div class="ttdoc">Master include file for project Includes all project includes and defines here. </div></div>
<div class="ttc" id="timer_8c_html_a6802af23bc1fe764b975683a0b37fc91"><div class="ttname"><a href="timer_8c.html#a6802af23bc1fe764b975683a0b37fc91">display_ts</a></div><div class="ttdeci">MEMSPACE void display_ts(ts_t *val)</div><div class="ttdoc">timespec structure in seconds.nanoseconds. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00167">timer.c:167</a></div></div>
<div class="ttc" id="time_8h_html"><div class="ttname"><a href="time_8h.html">time.h</a></div><div class="ttdoc">Common Linux/POSIX time functions. </div></div>
<div class="ttc" id="timer_8h_html_a49353e09a3623d95083574b87e9aadc5"><div class="ttname"><a href="timer_8h.html#a49353e09a3623d95083574b87e9aadc5">install_timers_isr</a></div><div class="ttdeci">MEMSPACE void install_timers_isr(void)</div></div>
<div class="ttc" id="timer_8c_html_a71c3fe0e245c7b08e03a2fe0fbd88844"><div class="ttname"><a href="timer_8c.html#a71c3fe0e245c7b08e03a2fe0fbd88844">kill_timer</a></div><div class="ttdeci">MEMSPACE int kill_timer(int timer)</div><div class="ttdoc">Delete &quot;Kill&quot; one user timer task. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00100">timer.c:100</a></div></div>
<div class="ttc" id="time_8h_html_afeece078c6706f33383bf11bbf584518"><div class="ttname"><a href="time_8h.html#afeece078c6706f33383bf11bbf584518">clockid_t</a></div><div class="ttdeci">uint16_t clockid_t</div><div class="ttdoc">type of clockid_t. </div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00038">time.h:38</a></div></div>
<div class="ttc" id="timer_8c_html_a182d70e09e9436c9c8a2e81b7597f206"><div class="ttname"><a href="timer_8c.html#a182d70e09e9436c9c8a2e81b7597f206">clock_task</a></div><div class="ttdeci">void clock_task(void)</div><div class="ttdoc">1000HZ timer task </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00276">timer.c:276</a></div></div>
<div class="ttc" id="timer_8c_html_adf029ed50e104cc3c16bcb7cf7d58f8c"><div class="ttname"><a href="timer_8c.html#adf029ed50e104cc3c16bcb7cf7d58f8c">clock_elapsed_begin</a></div><div class="ttdeci">MEMSPACE void clock_elapsed_begin()</div><div class="ttdoc">Store current struct timespec in __clock_elapsed. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00184">timer.c:184</a></div></div>
<div class="ttc" id="timer_8c_html_a35f94fb84f1b626d8d1ace062b26c932"><div class="ttname"><a href="timer_8c.html#a35f94fb84f1b626d8d1ace062b26c932">set_timers</a></div><div class="ttdeci">MEMSPACE int set_timers(void(*handler)(void), int timer)</div><div class="ttdoc">Install a user timer task. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00060">timer.c:60</a></div></div>
<div class="ttc" id="timer_8c_html_a62b37d3b3acfee789af6a9dbd47f7267"><div class="ttname"><a href="timer_8c.html#a62b37d3b3acfee789af6a9dbd47f7267">delete_all_timers</a></div><div class="ttdeci">MEMSPACE void delete_all_timers()</div><div class="ttdoc">Clear ALL user timer tasks. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00117">timer.c:117</a></div></div>
<div class="ttc" id="structtimespec_html_afc3302668d7cb5952f590da69fdd4955"><div class="ttname"><a href="structtimespec.html#afc3302668d7cb5952f590da69fdd4955">timespec::tv_sec</a></div><div class="ttdeci">time_t tv_sec</div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00090">time.h:90</a></div></div>
<div class="ttc" id="timer_8h_html"><div class="ttname"><a href="timer_8h.html">timer.h</a></div><div class="ttdoc">timer functions </div></div>
<div class="ttc" id="cpu_8h_html_a8ca99a0a57619094a5bff3a009b5cea8"><div class="ttname"><a href="cpu_8h.html#a8ca99a0a57619094a5bff3a009b5cea8">snprintf</a></div><div class="ttdeci">#define snprintf(s, size, format, args...)</div><div class="ttdef"><b>Definition:</b> <a href="cpu_8h_source.html#l00081">cpu.h:81</a></div></div>
<div class="ttc" id="structTIMERS_html_a4326e05ca52d80147efafd0d246ecb41"><div class="ttname"><a href="structTIMERS.html#a4326e05ca52d80147efafd0d246ecb41">TIMERS::user_timer_handler</a></div><div class="ttdeci">void(* user_timer_handler)(void)</div><div class="ttdef"><b>Definition:</b> <a href="timer_8h_source.html#l00037">timer.h:37</a></div></div>
<div class="ttc" id="timer_8c_html_ae997c45cc4d164ce0b47a44b370651ec"><div class="ttname"><a href="timer_8c.html#ae997c45cc4d164ce0b47a44b370651ec">timers_enabled</a></div><div class="ttdeci">static int timers_enabled</div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00043">timer.c:43</a></div></div>
<div class="ttc" id="timer_8c_html_a7faad7f12590c5756441f44a069f60d5"><div class="ttname"><a href="timer_8c.html#a7faad7f12590c5756441f44a069f60d5">clock_clear</a></div><div class="ttdeci">MEMSPACE void clock_clear()</div><div class="ttdoc">clear time and timezone to 0. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00221">timer.c:221</a></div></div>
<div class="ttc" id="timer_8h_html_ac0ca52f7bb0e2b7993bbcb75495d7904"><div class="ttname"><a href="timer_8h.html#ac0ca52f7bb0e2b7993bbcb75495d7904">SYSTEM_TASK_TIC_NS</a></div><div class="ttdeci">#define SYSTEM_TASK_TIC_NS</div><div class="ttdoc">System task in HZ. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8h_source.html#l00047">timer.h:47</a></div></div>
<div class="ttc" id="timer_8c_html_a4ebca9883466f2cc6fea0547e0e64e79"><div class="ttname"><a href="timer_8c.html#a4ebca9883466f2cc6fea0547e0e64e79">clock_settime</a></div><div class="ttdeci">MEMSPACE int clock_settime(clockid_t clk_id, const struct timespec *ts)</div><div class="ttdoc">Set system clock using seconds and nonoseconds - POSIX function. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00345">timer.c:345</a></div></div>
<div class="ttc" id="timer_8c_html_a296c5d3efac4bc56fc12fe3626f7d4b6"><div class="ttname"><a href="timer_8c.html#a296c5d3efac4bc56fc12fe3626f7d4b6">disable_timers</a></div><div class="ttdeci">MEMSPACE void disable_timers()</div><div class="ttdoc">Disable all timer tasks. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00235">timer.c:235</a></div></div>
<div class="ttc" id="structtimespec_html_ae3c7510dafa8cbcaede866ed13c99683"><div class="ttname"><a href="structtimespec.html#ae3c7510dafa8cbcaede866ed13c99683">timespec::tv_nsec</a></div><div class="ttdeci">long tv_nsec</div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00091">time.h:91</a></div></div>
<div class="ttc" id="cpu_8h_html_a070d2ce7b6bb7e5c05602aa8c308d0c4"><div class="ttname"><a href="cpu_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a></div><div class="ttdeci">#define NULL</div><div class="ttdef"><b>Definition:</b> <a href="cpu_8h_source.html#l00055">cpu.h:55</a></div></div>
<div class="ttc" id="timer_8c_html_a3b37602023ba3cdbbe1394f43abbef2c"><div class="ttname"><a href="timer_8c.html#a3b37602023ba3cdbbe1394f43abbef2c">_ts_to_str</a></div><div class="ttdeci">static char _ts_to_str[32]</div><div class="ttdoc">timespec structure in seconds.nanoseconds in string. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00153">timer.c:153</a></div></div>
<div class="ttc" id="timer_8c_html_a0ea4c1291946db41f55937b7cc3dc40c"><div class="ttname"><a href="timer_8c.html#a0ea4c1291946db41f55937b7cc3dc40c">timers_configured</a></div><div class="ttdeci">static int timers_configured</div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00044">timer.c:44</a></div></div>
<div class="ttc" id="mathio_8h_html"><div class="ttname"><a href="mathio_8h.html">mathio.h</a></div><div class="ttdoc">Math IO functions, and verious conversion code with floating point support. </div></div>
<div class="ttc" id="timer_8c_html_a335451dd774ecb4b696d501b4c1b6f30"><div class="ttname"><a href="timer_8c.html#a335451dd774ecb4b696d501b4c1b6f30">__clock</a></div><div class="ttdeci">volatile ts_t __clock</div><div class="ttdoc">System Clock Time. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00038">timer.c:38</a></div></div>
<div class="ttc" id="timer_8h_html_a9827e02881cff25ff30c35c7d8ed3ac4"><div class="ttname"><a href="timer_8h.html#a9827e02881cff25ff30c35c7d8ed3ac4">enable_system_task</a></div><div class="ttdeci">MEMSPACE void enable_system_task(void)</div></div>
<div class="ttc" id="timer_8c_html_a9f3dff4c1cc1701dc99d7e1d30ffcc06"><div class="ttname"><a href="timer_8c.html#a9f3dff4c1cc1701dc99d7e1d30ffcc06">clock_elapsed_end</a></div><div class="ttdeci">MEMSPACE void clock_elapsed_end(char *msg)</div><div class="ttdoc">Subtract and display time difference from clock_elapesed_begin(). </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00200">timer.c:200</a></div></div>
<div class="ttc" id="timer_8c_html_a41fb2edea84c2f17c7c6ad6ff87baeff"><div class="ttname"><a href="timer_8c.html#a41fb2edea84c2f17c7c6ad6ff87baeff">ts_to_str</a></div><div class="ttdeci">MEMSPACE char * ts_to_str(ts_t *val)</div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00155">timer.c:155</a></div></div>
<div class="ttc" id="cpu_8h_html_ad0fe97585b8891f5e4f2b9a6426330a4"><div class="ttname"><a href="cpu_8h.html#ad0fe97585b8891f5e4f2b9a6426330a4">MEMSPACE</a></div><div class="ttdeci">#define MEMSPACE</div><div class="ttdef"><b>Definition:</b> <a href="cpu_8h_source.html#l00025">cpu.h:25</a></div></div>
<div class="ttc" id="timer_8c_html_a11d81711e20909cf489fb56cbbb81558"><div class="ttname"><a href="timer_8c.html#a11d81711e20909cf489fb56cbbb81558">__clock_elapsed</a></div><div class="ttdeci">static ts_t __clock_elapsed</div><div class="ttdoc">Used for elapsed time calculations. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00176">timer.c:176</a></div></div>
<div class="ttc" id="mathio_8h_html_ad6078f8da2d30ecaef99e0c2d250c0c8"><div class="ttname"><a href="mathio_8h.html#ad6078f8da2d30ecaef99e0c2d250c0c8">printf</a></div><div class="ttdeci">MEMSPACE int printf(const char *format,...)</div></div>
<div class="ttc" id="timer_8c_html_acb0c9c995c634465d7d1f534bd862f8e"><div class="ttname"><a href="timer_8c.html#acb0c9c995c634465d7d1f534bd862f8e">init_timers</a></div><div class="ttdeci">MEMSPACE void init_timers()</div><div class="ttdoc">Setup all timers tasksi and enable interrupts. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00293">timer.c:293</a></div></div>
<div class="ttc" id="structTIMERS_html"><div class="ttname"><a href="structTIMERS.html">TIMERS</a></div><div class="ttdoc">user timer struct </div><div class="ttdef"><b>Definition:</b> <a href="timer_8h_source.html#l00035">timer.h:35</a></div></div>
<div class="ttc" id="structtimespec_html"><div class="ttname"><a href="structtimespec.html">timespec</a></div><div class="ttdoc">POSIX timespec. </div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00088">time.h:88</a></div></div>
<div class="ttc" id="cal__dex_8c_html_a7577d49f3bfffb1cf048eef843177784"><div class="ttname"><a href="cal__dex_8c.html#a7577d49f3bfffb1cf048eef843177784">L</a></div><div class="ttdeci">#define L(x)</div><div class="ttdef"><b>Definition:</b> <a href="cal__dex_8c_source.html#l00054">cal_dex.c:54</a></div></div>
<div class="ttc" id="timer_8h_html_a45ccd72c3ad32c4f7a5a8ef74d2653b3"><div class="ttname"><a href="timer_8h.html#a45ccd72c3ad32c4f7a5a8ef74d2653b3">disable_system_task</a></div><div class="ttdeci">MEMSPACE void disable_system_task(void)</div></div>
<div class="ttc" id="timer_8c_html_a9ac29ed71adf6807175d24ab1fa622a7"><div class="ttname"><a href="timer_8c.html#a9ac29ed71adf6807175d24ab1fa622a7">__tzone</a></div><div class="ttdeci">tz_t __tzone</div><div class="ttdoc">System Time Zone. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00041">timer.c:41</a></div></div>
<div class="ttc" id="timer_8c_html_ab92d687bae984bd62c3d741f2ba614ed"><div class="ttname"><a href="timer_8c.html#ab92d687bae984bd62c3d741f2ba614ed">subtract_timespec</a></div><div class="ttdeci">MEMSPACE void subtract_timespec(ts_t *a, ts_t *b)</div><div class="ttdoc">subtract a-= b timespec * structures. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00135">timer.c:135</a></div></div>
<div class="ttc" id="timer_8h_html_a492a379b00d0ec04be9cd0994e0b42ae"><div class="ttname"><a href="timer_8h.html#a492a379b00d0ec04be9cd0994e0b42ae">MAX_TIMER_CNT</a></div><div class="ttdeci">#define MAX_TIMER_CNT</div><div class="ttdoc">Number of user timer tasks. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8h_source.html#l00029">timer.h:29</a></div></div>
<div class="ttc" id="timer_8c_html_ab507661341c93c415b27ed9d40839539"><div class="ttname"><a href="timer_8c.html#ab507661341c93c415b27ed9d40839539">clock_getres</a></div><div class="ttdeci">MEMSPACE int clock_getres(clockid_t clk_id, struct timespec *res)</div><div class="ttdoc">Read clock time resolution into struct timepec *ts - POSIX function. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00329">timer.c:329</a></div></div>
<div class="ttc" id="structtimezone_html"><div class="ttname"><a href="structtimezone.html">timezone</a></div><div class="ttdoc">POSIX timezone. </div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00078">time.h:78</a></div></div>
<div class="ttc" id="timer_8c_html_aa6e5b6a9c1fb8bc6e2093fca40600bf5"><div class="ttname"><a href="timer_8c.html#aa6e5b6a9c1fb8bc6e2093fca40600bf5">clock_gettime</a></div><div class="ttdeci">MEMSPACE int clock_gettime(clockid_t clk_id, struct timespec *ts)</div><div class="ttdoc">Generic clock_gettime() function WITHOUT high resolution. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00377">timer.c:377</a></div></div>
<div class="ttc" id="structtimezone_html_a3042f7eff6e1b980728def76b1fa0eb7"><div class="ttname"><a href="structtimezone.html#a3042f7eff6e1b980728def76b1fa0eb7">timezone::tz_minuteswest</a></div><div class="ttdeci">int tz_minuteswest</div><div class="ttdef"><b>Definition:</b> <a href="time_8h_source.html#l00080">time.h:80</a></div></div>
<div class="ttc" id="timer_8c_html_ac97e80c15c73721fbc9f5071f6681fac"><div class="ttname"><a href="timer_8c.html#ac97e80c15c73721fbc9f5071f6681fac">enable_timers</a></div><div class="ttdeci">MEMSPACE void enable_timers()</div><div class="ttdoc">Enable timer tasks. </div><div class="ttdef"><b>Definition:</b> <a href="timer_8c_source.html#l00248">timer.c:248</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jan 31 2018 21:22:16 for ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
